<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{margin: 0;padding: 0;}
        section{width: 540px;}
        ul{list-style: none;}
        .btn{width: 40px;height: 300px;font-size: 22px;}
        .pic{height: 300px;}
        .pic ul{display: flex;}
        .ctrl{text-align: center;}
    </style>
</head>
<body>
    <section>
        <div class="ctrl">
            <button type="button">fggfgfgfggfj</button>
        </div>
        <div class="pic">
            <ul>
                <li><button class="btn">&lt;</button></li>
                <li><img src="" /></li>
                <li><button class="btn">&gt;</button></li>
            </ul>
        </div>
    </section>
    <script>
        var btns = document.querySelectorAll('button')
        var pic = document.querySelector('img')
        var num = 1
        pic.src = "img/"+num+".jpg"
        btns[1].onclick = function(){
            num--
            if(num<1 ){
                num=1
                pic.src="img/"+num+".jpg"
            }else{
                pic.src="img/"+num+".jpg"
            }
        }

        btns[2].onclick = function(){
            num++
            if(num>4){
                num=4
                pic.src="img/"+num+".jpg"
            }else{
                pic.src="img/"+num+".jpg"
            }
        }
    </script>
</body>
</html>